package com.csc.training.DAO;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.Transaction;

import com.csc.training.bean.Class;
import com.csc.training.inf.ClassDAO;
import com.googlecode.s2hibernate.struts2.plugin.annotations.SessionTarget;
import com.googlecode.s2hibernate.struts2.plugin.annotations.TransactionTarget;

public class ClassDAOImpl implements ClassDAO {

	@SessionTarget
	Session session;

	@TransactionTarget
	Transaction transaction;

	@Override
	public List<Class> listAllClass() {
		return session.createQuery("From Class").list();
	}

	@Override
	public Class getClassByName(String className) {
		Class classStudent;
		classStudent = (Class)session.createQuery(
				"From Class c where c.className = :classname").setParameter(
				"classname", className).list().get(0);
		return classStudent;

	}

}
